load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "domain",
    srcs = [
        "domain.go",
        "domain_sysvars.go",
        "domainctx.go",
        "extract.go",
        "historical_stats.go",
        "optimize_trace.go",
        "plan_replayer.go",
        "plan_replayer_dump.go",
        "ru_stats.go",
        "runaway.go",
        "schema_checker.go",
        "schema_validator.go",
        "sysvar_cache.go",
        "test_helper.go",
        "topn_slow_query.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/domain",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/streamhelper",
        "//br/pkg/streamhelper/daemon",
        "//pkg/bindinfo",
        "//pkg/config",
        "//pkg/ddl",
        "//pkg/ddl/notifier",
        "//pkg/ddl/placement",
        "//pkg/ddl/schematracker",
        "//pkg/ddl/systable",
        "//pkg/ddl/util",
        "//pkg/disttask/framework/scheduler",
        "//pkg/disttask/framework/storage",
        "//pkg/disttask/framework/taskexecutor",
        "//pkg/domain/globalconfigsync",
        "//pkg/domain/infosync",
        "//pkg/domain/metrics",
        "//pkg/errno",
        "//pkg/infoschema",
        "//pkg/infoschema/metrics",
        "//pkg/infoschema/perfschema",
        "//pkg/keyspace",
        "//pkg/kv",
        "//pkg/meta",
        "//pkg/meta/autoid",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/owner",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/terror",
        "//pkg/planner/core/metrics",
        "//pkg/privilege/privileges",
        "//pkg/resourcegroup/runaway",
        "//pkg/sessionctx",
        "//pkg/sessionctx/sessionstates",
        "//pkg/sessionctx/sysproctrack",
        "//pkg/sessionctx/variable",
        "//pkg/statistics",
        "//pkg/statistics/handle",
        "//pkg/statistics/handle/autoanalyze",
        "//pkg/statistics/handle/initstats",
        "//pkg/statistics/handle/logutil",
        "//pkg/statistics/handle/util",
        "//pkg/store",
        "//pkg/store/helper",
        "//pkg/ttl/ttlworker",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/chunk",
        "//pkg/util/context",
        "//pkg/util/dbterror",
        "//pkg/util/disttask",
        "//pkg/util/domainutil",
        "//pkg/util/engine",
        "//pkg/util/etcd",
        "//pkg/util/execdetails",
        "//pkg/util/expensivequery",
        "//pkg/util/gctuner",
        "//pkg/util/globalconn",
        "//pkg/util/intest",
        "//pkg/util/logutil",
        "//pkg/util/mathutil",
        "//pkg/util/memory",
        "//pkg/util/memoryusagealarm",
        "//pkg/util/printer",
        "//pkg/util/replayer",
        "//pkg/util/servermemorylimit",
        "//pkg/util/sqlexec",
        "//pkg/util/sqlkiller",
        "//pkg/util/syncutil",
        "@com_github_burntsushi_toml//:toml",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_kvproto//pkg/pdpb",
        "@com_github_pingcap_log//:log",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//txnkv/transaction",
        "@com_github_tikv_pd_client//:client",
        "@com_github_tikv_pd_client//http",
        "@com_github_tikv_pd_client//resource_group/controller",
        "@io_etcd_go_etcd_client_v3//:client",
        "@io_etcd_go_etcd_client_v3//concurrency",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "domain_test",
    timeout = "short",
    srcs = [
        "db_test.go",
        "domain_test.go",
        "domain_utils_test.go",
        "domainctx_test.go",
        "extract_test.go",
        "main_test.go",
        "plan_replayer_handle_test.go",
        "plan_replayer_test.go",
        "ru_stats_test.go",
        "schema_checker_test.go",
        "schema_validator_test.go",
        "topn_slow_query_test.go",
    ],
    embed = [":domain"],
    flaky = True,
    shard_count = 30,
    deps = [
        "//pkg/config",
        "//pkg/ddl",
        "//pkg/domain/infosync",
        "//pkg/errno",
        "//pkg/infoschema",
        "//pkg/keyspace",
        "//pkg/kv",
        "//pkg/meta",
        "//pkg/meta/model",
        "//pkg/metrics",
        "//pkg/parser/ast",
        "//pkg/parser/auth",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/terror",
        "//pkg/server",
        "//pkg/session",
        "//pkg/sessionctx/variable",
        "//pkg/store/mockstore",
        "//pkg/testkit",
        "//pkg/testkit/testsetup",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/mathutil",
        "//pkg/util/mock",
        "//pkg/util/replayer",
        "//pkg/util/stmtsummary/v2:stmtsummary",
        "@com_github_ngaut_pools//:pools",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_kvproto//pkg/resource_manager",
        "@com_github_prometheus_client_model//go",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//oracle",
        "@com_github_tikv_client_go_v2//txnkv/transaction",
        "@com_github_tikv_pd_client//:client",
        "@io_etcd_go_etcd_tests_v3//integration",
        "@org_uber_go_goleak//:goleak",
    ],
)
